import { http } from '@/utils/http'
import type {
  memberProfile,
  updateProfileData,
  memberAddress,
  memberAddressList,
} from '@/types/member'
/**
 * 获取个人信息
 */
export const getMemberProfileAPI = () => {
  return http<memberProfile>({
    url: '/member/profile',
    method: 'GET',
    // 配置项
  })
}
/**
 * 修改个人信息
 */
export const updateMemberProfileAPI = (data: updateProfileData) => {
  return http<memberProfile>({
    url: '/member/profile',
    method: 'PUT',
    data,
    // 配置项
  })
}
/**
 * 新增地址
 */
export const addMemberAddressAPI = (data: memberAddress) => {
  return http<{ id: number }>({
    url: '/member/address',
    method: 'POST',
    data,
    // 配置项
  })
}
/**
 * 修改地址
 */
export const updateMemberAddressAPI = (id: string, data: memberAddress) => {
  return http<{ id: string }>({
    url: `/member/address/${id}`,
    method: 'PUT',
    data,
    // 配置项
  })
}
/**
 * 获取地址
 */
export const getAddressAPI = () => {
  return http<memberAddressList[]>({
    url: '/member/address',
    method: 'GET',
    // 配置项
  })
}
/**
 * 获取地址详情
 */
export const getAddressDetailAPI = (id: string) => {
  return http<memberAddressList>({
    url: `/member/address/${id}`,
    method: 'GET',
    // 配置项
  })
}

/**
 * 删除地址
 */
export const deleteAddressAPI = (id: string) => {
  return http<{ id: string }>({
    url: `/member/address/${id}`,
    method: 'DELETE',
    // 配置项
  })
}
